home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / AmigaTalk_X / intuition / MenuFlags.st < prev    next >
Encoding:
Text File  |  2002-03-13  |  5.2 KB  |  112 lines

  1. " ------------------------------------------------------------------- "
  2. " MenuFlags Class is a Singleton class that allows the user           "
  3. " to reference Menu & MenuItem flags without knowing their            "
  4. " hexadecimal values.                                                 "
  5. ""
  6. " The User does NOT need to create one of these, since Intuition      "
  7. " Class will instantiate the only needed instance of this Class.  See "
  8. " the SetupIntuition.st source file for the method(s) that help the   "
  9. " User with this Class.                                               "
  10. ""
  11. " ALL singleton classes MUST contain the following:                   "
  12. ""
  13. "   the methods:  isSingleton AND privateSetup     AND                "
  14. "                 uniqueInstance Class instance variable.             "
  15. " ------------------------------------------------------------------- "
  16.  
  17. Class MenuFlags :Dictionary ! uniqueInstance !
  18. [
  19.    isSingleton
  20.      ^ true  
  21. |  
  22.    privateNew ! newinstance !
  23.      newinstance <- super new.
  24.  
  25.      ^ newinstance
  26. |
  27.    new
  28.      ^ self privateSetup
  29. |
  30.    privateSetup
  31.      (uniqueInstance isNil)
  32.        ifTrue: [uniqueInstance <- self privateNew.
  33.  
  34.                 self at: #MENUENABLED put: 1. " whether or not this menu is enabled "
  35.  
  36.                 " FLAGS SET BY INTUITION (For Menus): "
  37.  
  38.                 self at: #MIDRAWN     put: 16r100. " this menu's items are currently drawn "
  39.  
  40.                 self at: #CHECKIT     put: 1.  " set to indicate checkmarkable item "
  41.                 self at: #ITEMTEXT    put: 2.  " set if textual, clear if graphical item "
  42.                 self at: #COMMSEQ     put: 4.  " set if there's an command sequence "
  43.                 self at: #MENUTOGGLE  put: 8.  " set for toggling checks (else mut. exclude) "
  44.                 self at: #ITEMENABLED put: 16. " set if this item is enabled "
  45.  
  46.                 " these are the SPECIAL HIGHLIGHT FLAG state meanings: "
  47.                 
  48.                 self at: #HIGHFLAGS   put: 16rC0. " see definitions below for these bits "
  49.                 self at: #HIGHIMAGE   put: 0.     " use the user's 'select image' "
  50.                 self at: #HIGHCOMP    put: 16r40. " highlight by complementing the selectbox "
  51.                 self at: #HIGHBOX     put: 16r80. " highlight by 'boxing' the selectbox "
  52.                 self at: #HIGHNONE    put: 16rC0. " don't highlight "
  53.  
  54.                 " FLAGS SET BY BOTH APPLIPROG AND INTUITION: "
  55.  
  56.                 self at: #CHECKED     put: 16r100. " state of the checkmark "
  57.  
  58.                 " FLAGS SET BY INTUITION (For MenuItems & SubItems): "
  59.  
  60.                 self at: #ISDRAWN     put: 16r1000. " this item's subs are currently drawn "
  61.                 self at: #HIGHITEM    put: 16r2000. " this item is currently highlighted "
  62.                 self at: #MENUTOGGLED put: 16r4000. " this item was already toggled "
  63.  
  64.                 " NewMenus tags & flags: "                
  65.  
  66.                 self at: #NM_TITLE        put: 1.  "For NewMenus"
  67.                 self at: #NM_ITEM         put: 2.  "For NewMenus"
  68.                 self at: #NM_SUB          put: 3.  "For NewMenus"
  69.                 self at: #NM_END          put: 0.  "For NewMenus"
  70.                 self at: #NM_IGNORE       put: 64. "For NewMenus"
  71.                 self at: #NM_BARLABEL     put: -1. "For NewMenus"
  72.  
  73.                 self at: #IM_ITEM         put: 130. " Graphical menu item "
  74.                 self at: #IM_SUB          put: 131. " Graphical menu sub-item "
  75.                 self at: #NM_MENUDISABLED put: 1.   " Same as MENU_ENABLED "
  76.                 self at: #NM_ITEMDISABLED put: 16.  " Same as ITEMENABLED "
  77.  
  78.                 self at: #NM_COMMANDSTRING put: 4.     " Same as COMMSEQ "
  79.                 self at: #NM_FLAGMASK      put: 16r39. "(~(COMMSEQ | ITEMTEXT | HIGHFLAGS))"
  80.                 self at: #NM_FLAGMASK_V39  put: 16r3D. "(~(ITEMTEXT | HIGHFLAGS))"
  81.  
  82.                 " These return codes can be obtained through the GTMN_SecondaryError tag "
  83.  
  84.                 " Too many menus, items, or subitems, menu has been trimmed down: "
  85.                 self at: #GTMENU_TRIMMED   put: 1. 
  86.                 self at: #GTMENU_INVALID   put: 2. " Invalid NewMenu array "
  87.                 self at: #GTMENU_NOMEM       put: 3. " Out of memory "
  88.                 
  89.                 self at: #GTMN_TextAttr    put: 16r80080031. " MenuItem font TextAttr "
  90.                 self at: #GTMN_FrontPen    put: 16r80080032. " MenuItem text pen color "
  91.                 
  92.                 " Pointer to Menu for use by LayoutMenuItems(): "
  93.                 self at: #GTMN_Menu       put: 16r8008003C. 
  94.  
  95.                 " Asks CreateMenus() to validate that this is a complete menu structure: "
  96.                 self at: #GTMN_FullMenu       put: 16r8008003E. 
  97.  
  98.                 " ti_Data is a pointer to ULONG to receive error reports from CreateMenus()"
  99.                 self at: #GTMN_SecondaryError put: 16r8008003F. 
  100.  
  101.                 " ti_Data is checkmark img to use: "
  102.                 self at: #GTMN_Checkmark      put: 16r80080041. 
  103.  
  104.                 " ti_Data is Amiga-key img to use: "
  105.                 self at: #GTMN_AmigaKey       put: 16r80080042. 
  106.  
  107.                 self at: #GTMN_NewLookMenus   put: 16r80080043. " ti_Data is boolean "
  108.                ].
  109.                
  110.      ^ self    "or ^ uniqueInstance??"
  111. ]
  112.